<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>在GitHub白嫖图床 | XY Blog</title><meta name="keywords" content="github"><meta name="author" content="XY"><meta name="copyright" content="XY"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="白嫖服务器">
<meta property="og:type" content="article">
<meta property="og:title" content="在GitHub白嫖图床">
<meta property="og:url" content="http://example.com/2022/06/29/%E7%99%BD%E5%AB%96%E5%9B%BE%E5%BA%8A/index.html">
<meta property="og:site_name" content="XY Blog">
<meta property="og:description" content="白嫖服务器">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/img/github.jfif">
<meta property="article:published_time" content="2022-06-29T15:56:00.000Z">
<meta property="article:modified_time" content="2023-03-29T15:25:56.109Z">
<meta property="article:author" content="XY">
<meta property="article:tag" content="博客">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/img/github.jfif"><link rel="shortcut icon" href="/img/liuxing.jpg"><link rel="canonical" href="http://example.com/2022/06/29/%E7%99%BD%E5%AB%96%E5%9B%BE%E5%BA%8A/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"简","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '在GitHub白嫖图床',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-03-29 23:25:56'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/liuxing.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">9</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">5</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标籤</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">XY Blog</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标籤</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">在GitHub白嫖图床</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-06-29T15:56:00.000Z" title="发表于 2022-06-29 23:56:00">2022-06-29</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-03-29T15:25:56.109Z" title="更新于 2023-03-29 23:25:56">2023-03-29</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF/">技术</a></span></div><div class="meta-secondline"></div></div></div><article class="post-content" id="article-container"><h3 id="在GitHub白嫖图床"><a href="#在GitHub白嫖图床" class="headerlink" title="在GitHub白嫖图床"></a>在GitHub白嫖图床</h3><h5 id="为什么要图床这个东西呢？（因为床也要睡觉）"><a href="#为什么要图床这个东西呢？（因为床也要睡觉）" class="headerlink" title="为什么要图床这个东西呢？（因为床也要睡觉）"></a>为什么要图床这个东西呢？（<del>因为床也要睡觉</del>）</h5><p>因为把图片放在博客的网站资源里面会导致博客加载十分缓慢，而且上传博客也会变得繁琐，如果我们是多平台分发自己的文章，这样就更繁琐了。所以我们需要使用图床存储文档中的图片，那么在使用图片的时候只要写上图片所在的网络地址就好了，这样比较使用静态图片体验显然要好很多。</p>
<h4 id="白嫖步骤"><a href="#白嫖步骤" class="headerlink" title="白嫖步骤"></a>白嫖步骤</h4><h5 id="1-配置GitHub"><a href="#1-配置GitHub" class="headerlink" title="1. 配置GitHub"></a>1. 配置GitHub</h5><h6 id="1-新建仓库存放图床"><a href="#1-新建仓库存放图床" class="headerlink" title="1.新建仓库存放图床"></a>1.新建仓库存放图床</h6><h6 id="2-生成token，用于picGo访问GitHub"><a href="#2-生成token，用于picGo访问GitHub" class="headerlink" title="2.生成token，用于picGo访问GitHub"></a>2.生成token，用于picGo访问GitHub</h6><p>选择左侧菜单的Developer settings</p>
<p><img src="http://img.sc-xy.top/img/developer.png" alt></p>
<p>之后选择左侧Personal access tokens，再点击Generate new token</p>
<p><img src="http://img.sc-xy.top/img/generate.png" alt></p>
<p>填写Note，勾选repo.</p>
<p><img src="http://img.sc-xy.top/img/setting.png" alt></p>
<p><strong>注意，生成的token只会在这里显示一次，所以记得单独保存下来哦。</strong></p>
<p><img src="http://img.sc-xy.top/img/token.png" alt></p>
<p>至此，Github的配置完成。</p>
<h5 id="2-配置picGo"><a href="#2-配置picGo" class="headerlink" title="2.配置picGo"></a>2.配置picGo</h5><h6 id="1-下载"><a href="#1-下载" class="headerlink" title="1.下载"></a>1.下载</h6><p><a target="_blank" rel="noopener" href="https://github.com/Molunerfinn/PicGo/releases">下载地址 </a></p>
<p>选择 picGo-Setup-XXX.exe下载软件安装包即可。</p>
<h6 id="2-配置"><a href="#2-配置" class="headerlink" title="2.配置"></a>2.配置</h6><ul>
<li><p>注册SM.MS账号，<a target="_blank" rel="noopener" href="https://sm.ms/">官方链接</a></p>
</li>
<li><p>生成token</p>
<p><img src="http://img.sc-xy.top/img/SM_MS.png" alt></p>
</li>
</ul>
<p><img src="http://img.sc-xy.top/img/generate_1.png" alt></p>
<p>复制Token到picGO配置上</p>
<p><img src="http://img.sc-xy.top/img/token_1.png" alt></p>
<ul>
<li><p>仓库名：[github用户名]/[第一步新建的仓库名称]</p>
<p>分支：默认master，从2020.10.01开始，github的默认分支名变更为main</p>
<p>设定token：第一步创建的token</p>
<p>指定存储路径：可填可不填，如果填写了，图片就会存储在img文件夹下</p>
<p>设定自定义域名：<a target="_blank" rel="noopener" href="https://cdn.jsdelivr.net/gh/[github用户名]/[仓库名]@main，注意，此处的分支一定要填写@main，否则默认使用master分支。而现在github创建的默认分支名为main，如果不指定，则会出现图片不能上传的情况。【踩坑两小时】">https://cdn.jsdelivr.net/gh/[github用户名]/[仓库名]@main，注意，此处的分支一定要填写@main，否则默认使用master分支。而现在github创建的默认分支名为main，如果不指定，则会出现图片不能上传的情况。【踩坑两小时】</a></p>
<p><img src="http://img.sc-xy.top/img/settings.png" alt></p>
</li>
</ul>
<p>至此，picGo配置结束。</p>
<p>你也就拥有了一个免费的图床</p>
<h3 id="后记"><a href="#后记" class="headerlink" title="后记"></a>后记</h3><p>本来打算是用Gitee（码云）来白嫖的，但是picGo下载对应插件一直失败，所以被迫转github。</p>
<p>虽然国人的东西还是那么难搞，但是还是希望国内开源环境越来越好，让更多的programmer能够得到更好的资源和更大的空间。（<del>让我能白嫖更多国内资源</del>）</p>
</article><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%8D%9A%E5%AE%A2/">博客</a></div><div class="post_share"><div class="social-share" data-image="/img/github.jfif" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2022/08/27/%E5%9B%BE%E5%BA%8A%E9%98%B2%E7%81%AB/"><img class="prev-cover" src="/img/tuchuang.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">在GitHub白嫖图床-后记</div></div></a></div><div class="next-post pull-right"><a href="/2022/06/28/markdown_%E6%96%B0%E6%B4%BB/"><img class="next-cover" src="/img/markdown.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">markdown新活</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2022/08/27/%E5%9B%BE%E5%BA%8A%E9%98%B2%E7%81%AB/" title="在GitHub白嫖图床-后记"><img class="cover" src="/img/tuchuang.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-27</div><div class="title">在GitHub白嫖图床-后记</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9C%A8GitHub%E7%99%BD%E5%AB%96%E5%9B%BE%E5%BA%8A"><span class="toc-number">1.</span> <span class="toc-text">在GitHub白嫖图床</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E5%9B%BE%E5%BA%8A%E8%BF%99%E4%B8%AA%E4%B8%9C%E8%A5%BF%E5%91%A2%EF%BC%9F%EF%BC%88%E5%9B%A0%E4%B8%BA%E5%BA%8A%E4%B9%9F%E8%A6%81%E7%9D%A1%E8%A7%89%EF%BC%89"><span class="toc-number">1.0.1.</span> <span class="toc-text">为什么要图床这个东西呢？（因为床也要睡觉）</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%99%BD%E5%AB%96%E6%AD%A5%E9%AA%A4"><span class="toc-number">1.1.</span> <span class="toc-text">白嫖步骤</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#1-%E9%85%8D%E7%BD%AEGitHub"><span class="toc-number">1.1.1.</span> <span class="toc-text">1. 配置GitHub</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-%E6%96%B0%E5%BB%BA%E4%BB%93%E5%BA%93%E5%AD%98%E6%94%BE%E5%9B%BE%E5%BA%8A"><span class="toc-number">1.1.1.1.</span> <span class="toc-text">1.新建仓库存放图床</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2-%E7%94%9F%E6%88%90token%EF%BC%8C%E7%94%A8%E4%BA%8EpicGo%E8%AE%BF%E9%97%AEGitHub"><span class="toc-number">1.1.1.2.</span> <span class="toc-text">2.生成token，用于picGo访问GitHub</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AEpicGo"><span class="toc-number">1.1.2.</span> <span class="toc-text">2.配置picGo</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-%E4%B8%8B%E8%BD%BD"><span class="toc-number">1.1.2.1.</span> <span class="toc-text">1.下载</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AE"><span class="toc-number">1.1.2.2.</span> <span class="toc-text">2.配置</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%8E%E8%AE%B0"><span class="toc-number">2.</span> <span class="toc-text">后记</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2023 By XY</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, welcome to my blog! <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn"><img class="icp-icon" src="https://img.alicdn.com/tfs/TB1..50QpXXXXX7XpXXXXXXXXXX-40-40.png"><span>蜀ICP备2022030939号</span></a> <a href="https://icp.gov.moe/?keyword=20220702" target="_blank">萌ICP备20220702号</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><div class="js-pjax"><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="true"></script></div></body></html>